package com.lkx.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lkx.common.R;
import com.lkx.pojo.Orders;
import com.lkx.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: com.lkx.controller.OrderController
 * @author: likaixin
 * @create: 2022年11月27日 10:58
 * @desc:
 */
@RestController
@Slf4j
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /**
     * @Date:  2022-11-27
     * @Time:  11:00
     * @Param: [orders]
     * @return: com.lkx.common.R<java.lang.String>
     * @desc: 用户下单
     **/
    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        log.info("接收到订单：{}",orders);
        orderService.submit(orders);
        return R.success("用户下单成功");
    }
    @GetMapping("/userPage")
    public R<Page> showOrders(int page,int pageSize){
        R<Page> listR = orderService.showOrders(page, pageSize);
        return listR;
    }
    @GetMapping("/page")
    public R<Page> showOrderDetails(Integer page,Integer pageSize){
        R<Page> listR = orderService.showOrders(page, pageSize);
        return listR;

    }
}
